﻿using System;
using System.Collections.Generic;
using System.Linq;
using System.Text;
using DAO;
using DTO;
using System.Data.SqlClient;
using System.Data;
namespace DAO
{
    public partial class NguyenVatLieu_DAO
    {
        public bool ThemNVL(NguyenVatLieu nguyenvatlieu_dto)
        {
            DataProvider dp = new DataProvider();
            SqlParameter[] Parameter = new SqlParameter[5];

            Parameter[0] = new SqlParameter("@MaNVL", nguyenvatlieu_dto.MaNuyenVatLieu);
            Parameter[1] = new SqlParameter("@MaLoaiNVL", nguyenvatlieu_dto.MaLoaiNVL);
            Parameter[2] = new SqlParameter("@TenNVL", nguyenvatlieu_dto.TenNVl);
            Parameter[3] = new SqlParameter("@SoLuongTon", nguyenvatlieu_dto.SoLuongTon);
            Parameter[4] = new SqlParameter("@DVT", nguyenvatlieu_dto.DonViTinh);
            return dp.ExecutenonQuery("sp_ThemNguyenVatLieu", Parameter);
        }
        public bool CapNhatNVL(NguyenVatLieu nguyenvatlieu_dto)
        {
            DataProvider dp = new DataProvider();
            SqlParameter[] Parameter = new SqlParameter[5];

            Parameter[0] = new SqlParameter("@MaNVL", nguyenvatlieu_dto.MaNuyenVatLieu);
            Parameter[1] = new SqlParameter("@MaLoaiNVL", nguyenvatlieu_dto.MaLoaiNVL);
            Parameter[2] = new SqlParameter("@TenNVL", nguyenvatlieu_dto.TenNVl);
            Parameter[3] = new SqlParameter("@SoLuongTon", nguyenvatlieu_dto.SoLuongTon);
            Parameter[4] = new SqlParameter("@DVT", nguyenvatlieu_dto.DonViTinh);
            return dp.ExecutenonQuery("sp_CapNhatNVL", Parameter);
        }
        public bool XoaNVL(NguyenVatLieu nguyenvatlieu_dto)
        {
            DataProvider dp = new DataProvider();
            SqlParameter[] Parameter = new SqlParameter[1];

            Parameter[0] = new SqlParameter("@MaNVL", nguyenvatlieu_dto.MaNuyenVatLieu);
            return dp.ExecutenonQuery("sp_XoaNVL", Parameter);
        }
        public DataTable DanhSachNVL()
        {
            DataProvider dp = new DataProvider();
            DataTable dt = new DataTable();

            dt = dp.ExecuteQuery("sp_DanhSachNVL");
            return dt;
        }
        public string MaNVLTang()
        {
            DataProvider dp = new DataProvider();
            DataTable dt = new DataTable();

            dt = dp.ExecuteQuery("sp_MaNVL_Tang");
            return dt.Rows[0][0].ToString();
        }
        public DataTable DanhSachNVL_Ma(string strMa)
        {
            DataProvider dp = new DataProvider();
            DataTable dt = new DataTable();
            SqlParameter[] Parameter = new SqlParameter[1];

            Parameter[0] = new SqlParameter("@MaNVL", strMa);
            dt = dp.ExecuteQuery("sp_DanhSachNVL_Ma", Parameter);
            return dt;
        }
        public DataTable DanhSachNVL_MaLoaiNVL(string strMa)
        {
            DataProvider dp = new DataProvider();
            DataTable dt = new DataTable();
            SqlParameter[] Parameter = new SqlParameter[1];

            Parameter[0] = new SqlParameter("@MaLoaiNVL", strMa);
            dt = dp.ExecuteQuery("sp_DanhSachNVL_MaLoaiNVL", Parameter);
            return dt;
        }
    }
}
